package com.etc.threaddemo;

/**
 * @author: knowno
 * @create: 2024-09-13 09:16
 * @Version 1.0
 *
 * 1 线程实现方式1：继承Thread类
 **/
public class TestThread2 {
    public static void main(String[] args) {


        MyThread myThread1 = new MyThread();

        MyThread myThread2 = new MyThread();

        myThread1.start(); //只是让我们线程进入就绪状态.
        myThread2.start();

    }
}

class MyThread extends Thread {
    @Override
    public void run() {
        for (int i = 0; i < 10; i++) {
            System.out.println(Thread.currentThread().getId() + "," + Thread.currentThread().getName());
            //休眠
            try {
                Thread.sleep(10000);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
            //其他代码....

        }
    }
}
